#include <logger\LogManager.h>

#include <string>
#include <thread>
#include <vector>

void logging_task(int thread_id) {
  // 线程可以获取它们自己的logger实例，或者共享同一个
  // 我们的框架都能处理
  auto logger =
      Logging::LogManager::get_logger("Thread-" + std::to_string(thread_id));
  for (int i = 0; i < 20; ++i) {
    logger->info("Log entry " + std::to_string(i) + " from thread " +
                 std::to_string(thread_id));
  }
}
//
// int main() {
//  Logging::LogManager::initialize();
//
//  std::vector<std::thread> threads;
//  for (int i = 0; i < 5; ++i) {
//    threads.emplace_back(logging_task, i + 1);
//  }
//
//  for (auto& t : threads) {
//    t.join();
//  }
//
//  Logging::LogManager::shutdown();
//  return 0;
//}

/*预期输出：来自5个线程的100条日志消息将以交错但完整的形式打印到控制台。例如：

[HH:MM:SS.ms] [info] [Thread-2] Log entry 0 from thread 2
[HH:MM:SS.ms] [info] [Thread-1] Log entry 0 from thread 1
[HH:MM:SS.ms] [info] [Thread-4] Log entry 0 from thread 4
[HH:MM:SS.ms] [info] [Thread-3] Log entry 0 from thread 3
...
*/